/**
 * Created by pig2guang on 2017/5/18.
 */
$(function () {
    $('#md5_login_form').submit(function () {
        var salt = "{*nbsjt*asar#cdxd#}";
        var pwd = $('#password').val();
        var md5pwd = $.md5(pwd + salt);
        $.ajax({
            url: 'loginCheckMd5User',
            cache: false,
            dateType: 'json',
            contentType: "application/json;charset=utf-8",
            type: "post",
            data: JSON.stringify({
                username: $("#username").val(),
                password: md5pwd,
            }),
            success: function (data) {
                if (data == 200) {
                    alert("登录成功");
                    window.location.href = "hello";
                }
                else {
                    alert("登录失败!用户名或密码错误！");
                }
            },
            error: function (xhr) {
                alert('servlet出错\n' + xhr.status + '\n' + xhr.responseText);
            }
        });
    })
});
